package com.homework.service.impl;

import com.homework.dao.StudentDAO;
import com.homework.dao.impl.StudentDAOImpl;
import com.homework.entity.Student;
import com.homework.service.StudentService;

import java.util.List;

/**
 * @author: XiangHu
 * @date: 2025年02月28日 16:55
 * @describe:
 */

public class StudentServiceImpl implements StudentService {
    private StudentDAO studentDAO = new StudentDAOImpl();

    @Override
    public List<Student> findAllStudents() {
        return studentDAO.selectAllStudents();
    }

    @Override
    public Student findStudentById(int id) {
        return (Student) studentDAO.findStudentById(id);
    }

    @Override
    public List<Student> searchStudentsByName(String keyword) {
        return studentDAO.searchStudentsByName(keyword);
    }

    @Override
    public int addStudent(Student student) {
        studentDAO.insertStudent(student);
        return 0;
    }

    @Override
    public int updateStudent(Student student) {
        studentDAO.updateStudent(student);
        return 0;
    }

    @Override
    public int deleteStudent(int id) {
        studentDAO.deleteStudent(id);
        return id;
    }
}